import { createApp } from 'vue'
// iview plus
import ViewUIPlus from 'view-ui-plus'
import 'view-ui-plus/dist/styles/viewuiplus.css'

import 'highlight.js/styles/a11y-dark.css'

import VueHighlightJS from '@highlightjs/vue-plugin'
global.hljs = require('highlight.js');

import VueCodemirror from "codemirror-editor-vue3";

// 挂载全局API
import configGlobalAPI from '@mods/globalAPI'
import {
    storeInstance,
    routerInstance,
    vueI18nInstance
} from '@mods/index'

// 引入vxe-table
// import 'xe-utils'
// import VXETable from 'vxe-table'
// import 'vxe-table/lib/style.css'

import "@mods/style/font_icon/iconfont.css";
import "@mods/style/font_system/iconfont.css";

import { extendStorage, syncSessionStorage, initEnvPrefix, updateVersion, handleHostname } from '@mods/utils/tools';
import { LogoutBase } from "@mods/service/base";
import Cookies from "js-cookie";
import recode from '@mods/utils/recode';



import mixins from "./mixins";

// 生产环境去掉警告

//必须先初始化global.SYSID
global.SYSID = JSON.parse(Cookies.get("organization") || '{}').id;
global.DOMAIN = handleHostname('.localhost');

import routes from "./router/index";
import locale from "./locale/index";
import store from "./store/index";
// import mixins from "./mixins";
import LoadScript from 'vue-plugin-load-script';

// 引入css
import "./style/index.scss";

// import 'highlight.js/lib/common'

//同步storage
syncSessionStorage();
//初始化环境前缀
initEnvPrefix(process.env.VUE_APP_HOST_PREFIX);
//是否版本更新
updateVersion(LogoutBase);
//扩展storage
extendStorage();

recode();

const vueI18nIns = vueI18nInstance(locale)
const app = createApp({})
    .use(storeInstance(store))
    .use(routerInstance(routes))
    .use(vueI18nIns)
    .use(ViewUIPlus, {
        vueI18nIns
    })
    .use(VueHighlightJS)
    .use(VueCodemirror)
    .use(LoadScript)
    // .use(LoadScript)
    // .use(VXETable)
    

app.mount('#app')

app.mixin(mixins)
// 去掉生产环境的警告
if (process.env.NODE_ENV === 'dev') {
    app.config.warnHandler = (msg,instance,trace)=>{}
}
// 挂载全局API
configGlobalAPI(app)

export default app
